package api

import (
	"github.com/astaxie/beego"
	"goblog/models/dao"
	"goblog/models"
)

type CategoryController struct {
	beego.Controller
	categoryDao *dao.CategoryDao
}

func (this *CategoryController) Get() {
	page, _ := this.GetInt("page", 1)
	size, _ := this.GetInt("size", 10)
	pid, _ := this.GetInt("pid", 0)
	level, _ := this.GetInt("level", 0)

	if this.categoryDao == nil {
		this.categoryDao = new(dao.CategoryDao)
	}
	var term = new(dao.CategoryTerm)
	term.Page = page
	term.Size = size
	term.Pid = pid
	term.Level = level
	this.categoryDao.Find(term)
	this.Data["json"] = models.JsonSuccess("", term);
	this.ServeJSON()
}
